package routes

import (
	"dealcenter/internal/handler"
	"github.com/gin-gonic/gin"
)

func InitRouter(ginRouter *gin.Engine) {
	// 用户
	dealcenterV1 := ginRouter.Group("/dealcenter/v1")
	{
		// 公开组
		dealcenterV1Nil := dealcenterV1.Group("/nil")
		{
			dealcenterV1Nil.GET("/confirm", handler.Confirm)
		}

		// 鉴权组
		dealcenterV1Def := dealcenterV1.Group("/def")
		{
			// sale
			dealcenterV1Def.GET("/sale/list", handler.SaleList)
			dealcenterV1Def.GET("/sale/detail/:id", handler.SaleDetail)

			dealcenterV1Def.POST("/sale", handler.SaleCreate)
			dealcenterV1Def.DELETE("/sale/:id", handler.SaleClose)

			// buy
			dealcenterV1Def.GET("/buy/list", handler.BuyList)
			dealcenterV1Def.GET("/buy/detail/:id", handler.BuyDetail)

			dealcenterV1Def.POST("/buy", handler.BuyCreate)
			dealcenterV1Def.DELETE("/buy/:id", handler.BuyClose)

			// deal
			dealcenterV1Def.GET("/deal/list", handler.DealList)
			dealcenterV1Def.GET("/deal/detail/:id", handler.DealDetail)
			dealcenterV1Def.DELETE("/deal/:id", handler.DealClose)

			dealcenterV1Def.GET("/deal/:id/link", handler.ConfirmLink)
		}

		// 系统组（不对外公开，内网访问）
		dealcenterV1Sys := dealcenterV1.Group("/sys")
		{
			// sale
			dealcenterV1Sys.GET("/sale/list", handler.SaleList)
			dealcenterV1Sys.GET("/sale/detail/:id", handler.SaleDetail)

			// buy
			dealcenterV1Sys.GET("/buy/list", handler.BuyList)
			dealcenterV1Sys.GET("/buy/detail/:id", handler.BuyDetail)

			// deal
			dealcenterV1Sys.GET("/deal/list", handler.DealList)
			dealcenterV1Sys.GET("/deal/detail/:id", handler.DealDetail)
		}
	}
}
